package example.processor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.stereotype.Component;


/**
 * BeanFactoryPostProcessor：BeanFactory的后置处理器
 * 在BeanFactory标准初始化之后调用，所有bean定义已经保存加载到beanfactory中，但是bean的实例还未创建
 */
@Component
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
            throws BeansException {
        System.out.println("MyBeanFactoryPostProcessor.postProcessBeanFactory...");
        //beanFactory中有几个bean
        int beanDefinitionCount = beanFactory.getBeanDefinitionCount();
        //beanFactory中bean的名字
        String[] beanDefinitionNames = beanFactory.getBeanDefinitionNames();
    }
}




